// pages/collection/collection.js
const app = getApp();
let Api = require('../../api/api.js');

Page({

    /**
     * 页面的初始数据
     */
    data: {
        collectionList:[],
        tipText:'',
        showToast:false,
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        let self = this;
        Api.get(app.globalData.mallDomain, {//18）获取收藏列表
            doShowCollectionList: 1,
            token: app.globalData.token,
        }).then(res => {
            self.setData({
                collectionList:res.data.list
            })
        })
    },
    
    /**
     * 监听组件lateralSpreads值的变化
     */
    changeState: function(e) {
        let self = this;
        if (e.detail != undefined && e.detail != null && e.detail != ''){
            self.setData({
                tipText: '取消收藏成功！',
                showToast: true
            })
            setTimeout(function () {
                self.setData({
                    tipText: '',
                    showToast: false
                })
            }, 1000)
        }
        
    }, 
    /**
     * 点击去逛逛
     */
    toIndex: function (e) {
        let self = this;
        wx.navigateTo({
            url: '../index/index'
        })
    }, 

})